<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.lp.cfg.ProConfig"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/WEB-INF/oss/iot/common/variable.jsp"%>
<%@ include file="/WEB-INF/oss/iot/common/variable_js.jsp"%>
<%@ include file="/WEB-INF/oss/iot/common/resource_lib.jsp"%>

<style type="text/css">
	.app-container{
		width: 100%;border-top:1px solid #ecf0f5;
		padding-top: 10px;
	}
	.box-white {
	    width: 97%;
	    min-width: 897px;
	    padding-bottom: 0;
	    margin: 0 auto;
	}
	.box {
	    padding: 10px;
	    border: 0!important;
	    position: relative;
	    border-radius: 3px;
	    background: #fff;
	    margin-bottom: 20px;
		margin: 0 auto;
	}
	.List-info{
		padding-top: 10px;
		padding-left: 10px;
	}
</style>
</head>
<body>
	<div>
		<div>
			<div class="mapContainer" >
				<div class="app-container">
					<div class="container-layout List-info">
						<div class="box join-device-box">
							<div class="clearfix" style="width: 600px;margin: 0 auto;">
								<div>
									<div class="ml-20" id="form_submit_add" config-option=" url:'/visual/display',
																			   submit:'.add-Btn',
																			   success:'sunccessReturn' " >
										<div id="form_submit_update"  config-option=" url:'/visual/display','method':'put',
																			   submit:'.add-Btn',
																			   success:'sunccessReturn' " >
											<div id="detail_get" config-option=" 'url':'/visual/display?id=$#init-id$' ">
												<input id="init-id" type-name="id" type="hidden">
												
												<div class="form-line">
													<span class="red">*</span>&nbsp;<span>组态应用名称：</span>
													<div class="pb-10 pt-10">
														<input placeholder="名称" validate="empty" type-name="name" class="input input-big" >
													</div>
												</div>
												
												<div class="form-line">
													<span class="red">*</span>&nbsp;<span>是否公开显示：</span>
													<div class="pb-10 pt-10">
														<select type-name="openflag" id="Selects" class="input input-big input-select" >
															<option value="0">公开</option>
															<option value="1">加密</option>
														</select>
													</div>	
												</div>
												
												<div id="form-line" class="form-line">
													<span class="red">*</span>&nbsp;<span>访问密码：</span>
													<div class="pb-10 pt-10">
														<input placeholder="访问密码" type="password" type-name="password" class="input input-big" validate="empty">
													</div>	
												</div>
												
												<div class="form-line">
													<span class="red">*</span>&nbsp;<span>访问链接：</span>
													<div class="pb-10 pt-10">
														<div class="form-group">
															<div class="field">
																<div class="input-group">
																	<span class="addon"></span>
																	<div style="display:flex;">
																		<input type="text" id="input" class="input" type-name="visitorname" size="20" placeholder="访问后缀" />
																		<button style="width:100px;" onclick="Copy()">一键复制</button>
																	</div>
																</div>
															</div>
														</div>
														
													
														
													</div>	
												</div>
												<div id="textss" style="display:none;">
												</div>
												<div class="form-line clearfix  pb-10">
													<button onclick="parent.layer.close(index);" style="background: #aaa;" class="cancel-btn layui-btn ml-20 border-gray float-right">取消</button>
													<button class="add-Btn  ml-10 float-right layui-btn layui-btn-normal">保存</button>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>

<script type="text/javascript">

//获取窗口索引
var index = parent.layer.getFrameIndex(window.name); 

function sunccessReturn(data){
	if(isOK(data)){
		tip("成功");
		setTimeout(function() {
			parent.layer.close(index);
			parent.app.initVisual() ;
		}, 1000);
		
	}else{
		tip(data.statusMsg);
	}
}

function Copy(){
	$('#textss').html(base_domain +"/service/"+$('#input').val())
	document.getElementById('textss').style.display = 'block'
	var val = document.getElementById('textss');
	window.getSelection().selectAllChildren(val);
    document.execCommand('Copy');
	document.getElementById('textss').style.display = 'none'
    alert('复制成功');
}

function successfunc(){
	var scene_id = $('.scene_id', parent.document).val(); 
	$(".scene_id").val( scene_id ) ;
}

$(function(){
	// 初始化url参数
	var id = GetQueryString("id");
	if(validater.empty(id)){
		manual_form_submit($("#form_submit_add"))
	}else{
		writeVal("init-id",id);
		manual_form_submit($("#form_submit_update"));
		manual_init_detail_get($("#detail_get"));
	}
	$(".addon").html(base_domain +"/service/" )
	
	$("#Select").change(function(){
		  if($("#Select").val() == 0){
			$('#form-line').css('display','none')
		}else{
			$('#form-line').css('display','block')
		}
	});
	setTimeout(function() {
			if($("#Selects").val() == 0){
				$('#form-line').css('display','none')
			}else{
				$('#form-line').css('display','block')
			}
		},100)

})

</script>
</html>